import {ADD_COUNT,ADD_TO_CART} from './mutation_type.js'

export default {
	async addCart(context,payload){
	    let oldproduct=context.state.cartList.find(item=>item.pid==payload.pid)
	    if(oldproduct){
	    oldproduct.count+=1
	    context.commit(ADD_COUNT,oldproduct)
	    return '商品数量+1';
	    }else{
	      context.commit(ADD_TO_CART,payload)
	      return '添加一个商品'
	    }
	}	
}